#!/bin/bash

echo "Checking if PyInstaller is installed..."
if ! pip show pyinstaller > /dev/null 2>&1; then
    echo "PyInstaller not found, installing..."
    pip install pyinstaller
else
    echo "PyInstaller is already installed"
fi

echo "Starting compilation..."
pyinstaller --noconfirm \
    --clean \
    --name "DataShadow" \
    --add-data "src/ui:src/ui" \
    --add-data "sources:sources" \
    --add-data "README.md:." \
    --hidden-import "pymysql" \
    --hidden-import "oracledb" \
    --hidden-import "pandas" \
    --hidden-import "numpy" \
    --hidden-import "openpyxl" \
    --hidden-import "tkinter" \
    --hidden-import "json" \
    --hidden-import "csv" \
    --onefile \
    --icon="sources/icon.png" \
    main.py

echo "Cleaning temporary files..."
rm -rf build
rm -f main.spec

echo "Compilation completed!"
echo "Executable file is located in dist directory" 